package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ShowingSchedule;
import com.ruoyi.system.service.IShowingScheduleService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 排片信息数据Controller
 * 
 * @author ruoyi
 * @date 2024-06-28
 */
@RestController
@RequestMapping("/system/screening")
public class ShowingScheduleController extends BaseController
{
    @Autowired
    private IShowingScheduleService showingScheduleService;

    /**
     * 查询排片信息数据列表
     */
    @PreAuthorize("@ss.hasPermi('system:screening:list')")
    @GetMapping("/list")
    public TableDataInfo list(ShowingSchedule showingSchedule)
    {
        startPage();
        List<ShowingSchedule> list = showingScheduleService.selectShowingScheduleList(showingSchedule);
        return getDataTable(list);
    }

    /**
     * 导出排片信息数据列表
     */
    @PreAuthorize("@ss.hasPermi('system:screening:export')")
    @Log(title = "排片信息数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ShowingSchedule showingSchedule)
    {
        List<ShowingSchedule> list = showingScheduleService.selectShowingScheduleList(showingSchedule);
        ExcelUtil<ShowingSchedule> util = new ExcelUtil<ShowingSchedule>(ShowingSchedule.class);
        util.exportExcel(response, list, "排片信息数据数据");
    }

    /**
     * 获取排片信息数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:screening:query')")
    @GetMapping(value = "/{showingId}")
    public AjaxResult getInfo(@PathVariable("showingId") Long showingId)
    {
        return success(showingScheduleService.selectShowingScheduleByShowingId(showingId));
    }

    /**
     * 新增排片信息数据
     */
    @PreAuthorize("@ss.hasPermi('system:screening:add')")
    @Log(title = "排片信息数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ShowingSchedule showingSchedule)
    {
        return toAjax(showingScheduleService.insertShowingSchedule(showingSchedule));
    }

    /**
     * 修改排片信息数据
     */
    @PreAuthorize("@ss.hasPermi('system:screening:edit')")
    @Log(title = "排片信息数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ShowingSchedule showingSchedule)
    {
        return toAjax(showingScheduleService.updateShowingSchedule(showingSchedule));
    }

    /**
     * 删除排片信息数据
     */
    @PreAuthorize("@ss.hasPermi('system:screening:remove')")
    @Log(title = "排片信息数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{showingIds}")
    public AjaxResult remove(@PathVariable Long[] showingIds)
    {
        return toAjax(showingScheduleService.deleteShowingScheduleByShowingIds(showingIds));
    }
}
